// 如果没有通过拦截器配置域名的话，可以在这里写上完整的URL(加上域名部分)
let hotSearchUrl = '/ebapi/store_api/hot_search';
let indexUrl = '/ebapi/public_api/index';

// 此处第二个参数vm，就是我们在页面使用的this，你可以通过vm获取vuex等操作，更多内容详见uView对拦截器的介绍部分：
// https://uviewui.com/js/http.html#%E4%BD%95%E8%B0%93%E8%AF%B7%E6%B1%82%E6%8B%A6%E6%88%AA%EF%BC%9F
const install = (Vue, vm) => {
	// 登录
	let login = (params = {}) => uni.post('store/passport/login', params);
	// 登录
	let wxlogin = (params = {}) => uni.post('store/passport/wxlogin', params);
	
	// 获取当前用户信息
	let getUserInfo = (params = {}) => uni.get('store/store.user/info', params);
	
	// 获取当前店铺信息
	let storeInfo = (params = {}) => uni.post('store/store/info', params);

	// 获取首页信息
	let fetchHomeStat = (params = {}) => uni.get('store/home/data', params);

	//获取订单
	let getOrder = (params = {}) => uni.get('store/order/list', params);

	//获取订单详情
	let getOrderDetail = (params = {}) => uni.get('store/order/detail', params);
	
    //接单操作
	let acceptOrder = (params = {}) => uni.post('store/order.delivery/accept', params);
	
	//手机端配送订单操作
	let deliveryBym = (params = {}) => uni.post('store/order.delivery/deliveryBym', params);
	
	// 商品分类
	let getGoodsCategory = (params = {}) => uni.get('store/category/list', params);

	// 商品 
	let getGoods = (params = {}) => uni.get('store/goods/list', params);

	// 商品 删除
	let removeGoods = (params = {}) => uni.post('store/goods/delete', params);

	// 商品 编辑
	let updateGoods = (params = {}) => uni.post('store/goods/edit', params);

	// 商品 创建
	let createGoods = (params = {}) => uni.post('store/goods/add', params);

	// 商品 详情
	let goodsDetail = (params = {}) => uni.post('store/goods/detail', params);

	// 商品 上下架
	let goodsState = (params = {}) => uni.post('store/goods/state', params);

	// 服务类型
	let serviceList = (params = {}) => uni.post('store/goods.service/all', params);

	// 会员价类型
	let userGradeList = (params = {}) => uni.post('store/user.grade/all&status=1', params);


	// 运费模板
	let deliveryList = (params = {}) => uni.get('store/setting.delivery/all', params);

    //获取订单
	let getOrderStatistics = (params = {}) => uni.get('store/order/orderStatistics', params);
	
	// 店铺 编辑
	let updateStore = (params = {}) => uni.post('store/store/edit', params);

	// 将各个定义的接口名称，统一放进对象挂载到vm.$u.api(因为vm就是this，也即this.$u.api)下
	uni.api = {
		getOrder,
		getOrderStatistics,
		getOrderDetail,
		acceptOrder,
		deliveryBym,
		login,
		wxlogin,
		getUserInfo,
		storeInfo,
		updateStore,
		fetchHomeStat,
		getGoodsCategory,
		getGoods,
		removeGoods,
		goodsDetail,
		goodsState,
		serviceList,
		userGradeList,
		updateGoods,
		createGoods,
		deliveryList
	};
}

export default {
	install
}